#ifndef CSVPARSER_H
#define CSVPARSER_H

#include <QVector>
#include <QHash>
#include <QPair>
#include <QFile>

class CsvParser
{
public:
    explicit CsvParser();

    typedef QHash<QString, QPair<QString, QString> > AttributeMap_t;

    /**
     * @brief ReadXmlFile_
     *
     * Used to read and parse the input CSV file
     */
    void ParseFile(QFile& rFile);

    const QVector<QString>& StaticGSOIDs()
    {
        return m_StaticGSOIDs;
    }

    const QVector<QString>& StaticGSOIDsRegExp()
    {
        return m_StaticGSOIDsRegExp;
    }

    const QString& TopRow()
    {
        return m_TopRow;
    }

    const AttributeMap_t& AttributeMap()
    {
        return m_StaticGSOIDsVsAttributes;
    }

private:
    void Reset_();

    /**
     * @brief m_StaticGSOIDs
     *
     * Contains all the static GSOIDs from the list of the attributes that
     * we are looking for
     *
     * @important
     * This vector contains the unique static GSOIDs in
     * THE SAME ORDER AS IN THE INPUT CSV FILE!
     *
     */
    QVector<QString> m_StaticGSOIDs;

    /**
     * @brief m_StaticGSOIDsRegExp
     *
     * This vector contains the same data as above, but in place of 0's it
     * contains \d+ , example:
     *
     * 1:1/2:0 is translated to:
     * ^1:1/2:\d+$
     *
     * Every element from this vector is a regular expression that will be
     * used to look for the GSOIDs from the XML file.
     */
    QVector<QString> m_StaticGSOIDsRegExp;

    /**
     * @brief m_StaticGSOIDsVsAttributes2
     *
     * Contains all the static GSOIDs from the list of the attributes that
     * we are looking for with their respective Attributes (ie. Pairs of
     * Attribute ID and Access)
     */
    AttributeMap_t m_StaticGSOIDsVsAttributes;

    /**
     * @brief m_InputCsvTopRow
     *
     * Contains the top row from the input CSV, should be something like:
     * "GSOID,Attribute ID,Access"
     */
    QString m_TopRow;
};

#endif // CSVPARSER_H
